﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FluentNHibernate.Mapping;

namespace Mindfor.Web.Modules.Catalog
{
	public class ProductMap : ClassMap<Product>
	{
		public ProductMap()
		{
			Table("Products");
			Id(m => m.Id);
			Map(m => m.Title).Length(255).Not.Nullable();
			Map(m => m.Price).Nullable();
			Map(m => m.TextShort).Nullable();
			Map(m => m.TextFull).Nullable();

			References<Category>(m => m.Category, "ProductCategoryId");
			HasMany<ProductImage>(m => m.Pictures).KeyColumn("ProductId").Inverse().Cascade.AllDeleteOrphan();
		}
	}
}